package com.yuanlrc.base.entity.common;

import com.yuanlrc.base.annotion.ValidateEntity;
import com.yuanlrc.base.entity.admin.BaseEntity;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;

/**
 * 2月24日
 * 物品实体类
 * @author Administrator
 *
 */
@Entity
@Table(name="bishe_goods")
@EntityListeners(AuditingEntityListener.class)
public class Goods extends BaseEntity {
	public static final int GOODS_STATUS_UP =1;//上架
	public static final int GOODS_STATUS_DOWN =2;//下架
	public static final int GOODS_STATUS_SOLD =3;//已售出

	public static final int GOODS_RECOMMEND_OFF =0;//不推荐
	public static final int GOODS_RECOMMEND_ON =1;//推荐

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	@ValidateEntity(required=true,requiredLeng=true,minLength=1,maxLength=30,errorRequiredMsg="物品名称不能为空!",errorMinLengthMsg="物品名称长度需大于1!",errorMaxLengthMsg="物品名称长度不能大于30!")
	@Column(name="name",nullable=false,length=32)
	private String name;//物品名称

	@ManyToOne
	@JoinColumn(name="home_user_id")
	private HomeUser homeUser;//所属用户

	@ManyToOne
	@JoinColumn(name="goods_category_id")
	private GoodsCategory goodsCategory;//物品分类

	@ValidateEntity(required=true,errorRequiredMsg="请填写出售价格",requiredMinValue = true,errorMinValueMsg = "出售价格不能小于0")
	@Column(name="sell_price",nullable=false,length=8)
	private String sellPrice;//出售价格

	@ValidateEntity(required=true,errorRequiredMsg="请填写库存",requiredMinValue = true,errorMinValueMsg = "库存不能小于0")
	@Column(name="stock",nullable=false,length=8)
	private String stock;//库存

	@ValidateEntity(required=true,errorRequiredMsg="请上传图片")
	@Column(name="photo",nullable=false,length=128)
	private String photo;//物品图标
	
	@Column(name="status",nullable=false,length=1)
	private Integer status = GOODS_STATUS_UP;//物品状态

	@Column(name="recommed",nullable=false,length=1)
	private Integer recommed = GOODS_RECOMMEND_OFF;//管理员是否推荐

	@ValidateEntity(required=true,requiredLeng=true,minLength=1,maxLength=1000,errorRequiredMsg="物品详情描述不能为空!",errorMinLengthMsg="物品详情描述长度需大于1!",errorMaxLengthMsg="物品详情描述长度不能大于1000!")
	@Column(name="content",nullable=false,length=1024)
	private String content;//物品详情描述

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public HomeUser getHomeUser() {
		return homeUser;
	}

	public void setHomeUser(HomeUser homeUser) {
		this.homeUser = homeUser;
	}

	public GoodsCategory getGoodsCategory() {
		return goodsCategory;
	}

	public void setGoodsCategory(GoodsCategory goodsCategory) {
		this.goodsCategory = goodsCategory;
	}

	public String getSellPrice() {
		return sellPrice;
	}

	public void setSellPrice(String sellPrice) {
		this.sellPrice = sellPrice;
	}

	public String getStock() {
		return stock;
	}

	public void setStock(String stock) {
		this.stock = stock;
	}

	public String getPhoto() {
		return photo;
	}

	public void setPhoto(String photo) {
		this.photo = photo;
	}


	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public static long getSerialVersionUID() {
		return serialVersionUID;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public Integer getRecommed() {
		return recommed;
	}

	public void setRecommed(Integer recommed) {
		this.recommed = recommed;
	}

	@Override
	public String toString() {
		return "Goods{" +
				"name='" + name + '\'' +
				", homeUser=" + homeUser +
				", goodsCategory=" + goodsCategory +
				", sellPrice='" + sellPrice + '\'' +
				", stock='" + stock + '\'' +
				", photo='" + photo + '\'' +
				", status=" + status +
				", recommed=" + recommed +
				", content='" + content + '\'' +
				'}';
	}
}
